home *** CD-ROM | disk | FTP | other *** search
-
- void ADDRESS_BOOK_TREE::alloc_data(NODE *to_node, void *from_data)
- {
- ADDRESS_BOOK_ENTRY *to = to_node->data;
- ADDRESS_BOOK_ENTRY *from = from_data;
-
- to->name = new char[strlen(from->name)+1];
- strcpy(to->name, from->name);
-
- to->street_address = new char[strlen(from->street_address)];
- strcpy(to->street_address, from->street_address);
-
- // etc. for other fields in an ADDRESS_BOOK_ENTRY
- }
-
- void ADDRESS_BOOK_TREE::delete_data(NODE *nptr)
- {
- ADDRESS_BOOK_ENTRY aptr = nptr->data;
-
- delete to->name;
- delete to->street_address;
- delete to->city;
- delete to->state;
- zip = 0L;
- }
-
- void ADDRESS_BOOK_TREE::compare(void *v1, void *v2, size_t size)
- {
- // This function compares the names in each entry, returning
- // <0 if d1->name < d2->name, 0 if d1->name == d2->name,
- // and >0 if d1->name > d2->name. This is very easy to do
- // by using the strcmpl() function. In this case the 'size'
- // argument is irrelevant.
-
- ADDRESS_BOOK_ENTRY *d1 = v1, *d2 = v2;
-
- return strcmpl(d1->name, d2->name);
- }
-
-